package cn.xopencode.appletweb.controller.record.robotroom;

import cn.xopencode.common.framework.vo.CommonResult;
import cn.xopencode.common.framework.vo.PageResult;
import cn.xopencode.recordservice.rpc.robotroom.dto.RobotRoomRecordCreateDTO;
import cn.xopencode.recordservice.rpc.robotroom.dto.RobotRoomRecordPageDTO;
import cn.xopencode.recordservice.rpc.robotroom.dto.RobotRoomRecordUpdateDTO;
import cn.xopencode.recordservice.rpc.robotroom.vo.RobotRoomRecordEmpRelVO;
import cn.xopencode.recordservice.rpc.robotroom.vo.RobotRoomRecordPageVO;
import cn.xopencode.recordservice.rpc.robotroom.vo.RobotRoomRecordUpdateVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

@Api(tags = "智能机器人班机柜间巡检记录 API")
@RestController
@RequestMapping("/robotroom")
@Validated
public class RobotRoomRecordController {

    /**
     * 根据查询条件 分页获取所有的智能机器人班机柜间巡检记录
     * @param pageDTO
     * @return
     */
    @PostMapping("/getAllByQuery")
    @ApiOperation("根据查询条件分页获取所有的智能机器人班机柜间巡检记录")
    public CommonResult<PageResult<RobotRoomRecordPageVO>> getPageRobotRoomRecord(RobotRoomRecordPageDTO pageDTO){
        PageResult<RobotRoomRecordPageVO> result = new PageResult<>();
        List<RobotRoomRecordPageVO> list = new ArrayList<>();

        RobotRoomRecordPageVO vo = new RobotRoomRecordPageVO();
        vo.setInspectionTime(new Date());
        vo.setEmpRels("张三、李四");
        list.add(vo);
        RobotRoomRecordPageVO vo2 = new RobotRoomRecordPageVO();
        vo2.setInspectionTime(new Date());
        vo2.setEmpRels("王一");
        list.add(vo2);

        result.setList(list);
        return CommonResult.success(result);
    }

    /**
     *  新增 智能机器人班机柜间巡检记录
     * @param roomDTO
     * @return
     */
    @PostMapping("/add")
    @ApiOperation("新增 智能机器人班机柜间巡检记录")
    public CommonResult<Integer> createRobotRoomRecord(@Valid RobotRoomRecordCreateDTO roomDTO){
        return CommonResult.success(1);
    }

    /**
     *  更新 智能机器人班机柜间巡检记录
     * @param roomDTO
     * @return
     */
    @PostMapping("/update")
    @ApiOperation("更新 智能机器人班机柜间巡检记录")
    public CommonResult<Integer> updateRobotRoomRecord(@Valid RobotRoomRecordUpdateDTO roomDTO){
        return CommonResult.success(1);
    }

    /**
     * 根据id获取智能机器人班机柜间巡检记录详细
     * @param roomId
     * @return
     */
    @GetMapping("/getById")
    @ApiOperation("根据id获取智能机器人班机柜间巡检记录详细")
    public CommonResult<RobotRoomRecordUpdateVO> getRobotRoomRecordById(String roomId){
        RobotRoomRecordUpdateVO vo = new RobotRoomRecordUpdateVO();
        vo.setInspectionTime(new Date());
        vo.setClean(true);
        vo.setEnTemperature(55.23);
        vo.setGas(false);
        vo.setEnTemperature(35.0);
        vo.setNormal(true);
        vo.setLineTemperature(45.12);
        vo.setId("332343242334");

        List<RobotRoomRecordEmpRelVO> list = new ArrayList<RobotRoomRecordEmpRelVO>();
        RobotRoomRecordEmpRelVO relVO = new RobotRoomRecordEmpRelVO();
        relVO.setEmpId("111");
        relVO.setId("11");
        relVO.setRecordId("332343242334");
        RobotRoomRecordEmpRelVO relVO2 = new RobotRoomRecordEmpRelVO();
        relVO2.setEmpId("222");
        relVO2.setId("22");
        relVO2.setRecordId("332343242334");
        list.add(relVO);
        list.add(relVO2);

        vo.setEmpList(list);
        return CommonResult.success(vo);
    }

}
